<nav class="navbar navbar-default" role="navigation">
	<div class="container-fluid">
		<div class="navbar-header">
			<a class="navbar-brand">Portal pracowniczy - rejestracja aplikacji!</a>
		</div>
		<p class="navbar-text">Jesteś zalogowany do aplikacji <strong><?php echo $this->app->getName(); ?></strong></p>
		<p class="navbar-text navbar-right"><a href="<?php echo $this->url(array('action' => 'login', 'logout' => 1)); ?>" class="navbar-link">Wyloguj <i class="glyphicon glyphicon-off"></i></a></p>
	</div>
</nav>
<div id="appData" class="panel panel-default">
	<div class="panel-heading">
		<h3 class="panel-title"><i class="glyphicon glyphicon-list-alt"></i> Bieżące dane aplikacji</h3>
	</div>
  <div class="panel-body">
  	<?php if ($this->appWaiting) : ?>
  		<div class="alert alert-info">Dane aplikacji czekają na akceptacje administratora.</div>	
  	<?php endif; ?>
	  <?php if ($this->appAccepted instanceof ApplicationDataSets) : ?>
	  	<h4>Podstawowe dane:</h4>
	  	<div class="row row-margin">
	    	<div class="col-xs-2 bold">Nazwa:</div>
	    	<div class="col-xs-2"><?php echo $this->appAccepted->getName(); ?></div>
	    	<div class="col-xs-2 bold">Opis:</div>
	    	<div class="col-xs-6"><?php echo $this->appAccepted->getDescription(); ?></div>
	    </div>
	    <div class="row row-margin2x">
	    	<div class="col-xs-2 bold">Nazwa (en):</div>
	    	<div class="col-xs-2"><?php echo $this->appAccepted->getNameEn(); ?></div>
	    	<div class="col-xs-2 bold">Opis (en):</div>
	    	<div class="col-xs-6"><?php echo $this->appAccepted->getDescriptionEn(); ?></div>
	    </div>
	    <h4 >Definicje informacji</h4>
	    <table class="table table-condensed table-small break-word">
				<thead>
					<tr>
						<th width="8%">Kod</th>
						<th width="15%">Etykieta</th>
						<th width="16%">Opis</th>
						<th width="15%">Etykieta (en)</th>
						<th width="16%">Opis (en)</th>
						<th width="10%">Typ danych</th>
						<th width="20%">Domylna wartość</th>
					</tr>
				</thead>
				<tbody>
					<?php if ($this->appAccepted->getApplicationDataDefss()->count() > 0) : ?>
						<?php foreach ($this->appAccepted->getApplicationDataDefss() as $def) : ?>
							<?php if ($def->getType() == 'info') : ?>
								<tr data-code="<?php echo $def->getCode(); ?>">
									<td><?php echo $def->getCode(); ?><input class="uniq-code data-code" type="hidden" value="<?php echo $def->getCode(); ?>" name="info[<?php echo $def->getCode(); ?>][code]"></td>
									<td><?php echo $def->getLabel(); ?><input class="data-label" type="hidden" value="<?php echo $def->getLabel(); ?>" name="info[<?php echo $def->getCode(); ?>][label]"></td>
									<td><?php echo $def->getDescription(); ?><input class="data-description" type="hidden" value="<?php echo $def->getDescription(); ?>" name="info[<?php echo $def->getCode(); ?>][desc]"></td>
									<td><?php echo $def->getLabelEn(); ?><input class="data-labelEn" type="hidden" value="<?php echo $def->getLabelEn(); ?>" name="info[<?php echo $def->getCode(); ?>][labelEn]"></td>
									<td><?php echo $def->getDescriptionEn(); ?><input class="data-descriptionEn" type="hidden" value="<?php echo $def->getDescriptionEn(); ?>" name="info[<?php echo $def->getCode(); ?>][descEn]"></td>
									<td><?php echo $def->getValueType(); ?><input class="data-type" type="hidden" value="<?php echo $def->getValueType(); ?>" name="info[<?php echo $def->getCode(); ?>][type]"></td>
									<td><?php echo $def->getDefaultValue(); ?><input class="data-default" type="hidden" value="<?php echo $def->getDefaultValue(); ?>" name="info[<?php echo $def->getCode(); ?>][default]"></td>
								</tr>
							<?php endif; ?>
						<?php endforeach; ?>
					<?php endif; ?>
				</tbody>
			</table>
			<h4>Linki</h4>
			<table class="table table-condensed table-small break-word">
				<thead>
					<tr>
						<th width="8%">Kod</th>
						<th width="15%">Etykieta</th>
						<th width="21%">Opis</th>
						<th width="15%">Etykieta (en)</th>
						<th width="21%">Opis (en)</th>
						<th width="20%">Domylna wartość</th>
					</tr>
				</thead>
				<tbody>
					<?php if ($this->appAccepted->getApplicationDataDefss()->count() > 0) : ?>
						<?php foreach ($this->appAccepted->getApplicationDataDefss() as $def) : ?>
							<?php if ($def->getType() == 'link') : ?>
								<tr data-code="<?php echo $def->getCode(); ?>">
									<td><?php echo $def->getCode(); ?><input class="uniq-code data-code" type="hidden" value="<?php echo $def->getCode(); ?>" name="link[<?php echo $def->getCode(); ?>][code]"></td>
									<td><?php echo $def->getLabel(); ?><input class="data-label" type="hidden" value="<?php echo $def->getLabel(); ?>" name="link[<?php echo $def->getCode(); ?>][label]"></td>
									<td><?php echo $def->getDescription(); ?><input class="data-description" type="hidden" value="<?php echo $def->getDescription(); ?>" name="link[<?php echo $def->getCode(); ?>][desc]"></td>
									<td><?php echo $def->getLabelEn(); ?><input class="data-labelEn" type="hidden" value="<?php echo $def->getLabelEn(); ?>" name="link[<?php echo $def->getCode(); ?>][labelEn]"></td>
									<td><?php echo $def->getDescriptionEn(); ?><input class="data-descriptionEn" type="hidden" value="<?php echo $def->getDescriptionEn(); ?>" name="link[<?php echo $def->getCode(); ?>][descEn]"></td>
									<td><?php echo $def->getDefaultValue(); ?><input class="data-default" type="hidden" value="<?php echo $def->getDefaultValue(); ?>" name="link[<?php echo $def->getCode(); ?>][default]"></td>
								</tr>
							<?php endif; ?>
						<?php endforeach; ?>
					<?php endif; ?>
				</tbody>
			</table>
	  <?php else : ?>
	  	<div class="alert alert-info">Dane aplikacji nie zostay jeszcze dodane.</div>
	  <?php endif; ?>
  </div>
</div>
<?php if ($this->app->getToModified() == 1) : ?>
	<form id="addSetForm" class="form-horizontal" role="form" action="<?php echo $this->url(array('action' => 'save.application.set'), null, false); ?>" action-to-accept="<?php echo $this->url(array('action' => 'accept.application.set'), null, false); ?>">
		<div class="panel panel-default">
			<div class="panel-heading">
				<h3 class="panel-title"><i class="glyphicon glyphicon-pencil"></i> Dodaj nowe dane dla aplikacji</h3>
			</div>
		  <div class="panel-body">
				<div class="form-group">
					<label for="inputName" class="col-xs-2 control-label">Nazwa</label>
					<div class="col-xs-10">
				    <div class="input-group">
				      <input type="text" class="form-control" id="inputName" name="name" placeholder="Nazwa w języku polskim" value="<?php echo ($this->appEditable !== null) ? $this->appEditable->getName() : null; ?>">
				      <span class="input-group-addon">*</span>
				    </div>
			    </div>
				</div>
				<div class="form-group">
					<label for="inputDesc" class="col-xs-2 control-label">Opis</label>
					<div class="col-xs-10">
						<div class="input-group">
				      <textarea class="form-control" id="inputDesc" name="description" placeholder="Opis w języku polskim"><?php echo ($this->appEditable !== null) ? $this->appEditable->getDescription() : null; ?></textarea>
				      <span class="input-group-addon">*</span>
				    </div>
			    </div>
				</div>
				<div class="form-group">
					<label for="inputNameEn" class="col-xs-2 control-label">Nazwa (en)</label>
					<div class="col-xs-10">
						<div class="input-group">
				      <input type="text" class="form-control" id="inputNameEn" name="nameEn" placeholder="Nazwa w języku angielskim" value="<?php echo ($this->appEditable !== null) ? $this->appEditable->getNameEn() : null; ?>">
				      <span class="input-group-addon">*</span>
				    </div>
			    </div>
				</div>
				<div class="form-group">
					<label for="inputDesc" class="col-xs-2 control-label">Opis (en)</label>
					<div class="col-xs-10">
						<div class="input-group">
				      <textarea class="form-control" id="inputDesc" name="descriptionEn" placeholder="Opis w języku angielskim"><?php echo ($this->appEditable !== null) ? $this->appEditable->getDescriptionEn() : null; ?></textarea>
				      <span class="input-group-addon">*</span>
				    </div>
			    </div>
				</div>
				<div class="row">
					<div class="col-xs-10 col-xs-offset-2">* - pola wymagane</div>
				</div>
				<div class="margin-bottom">
					<h4>Definicje informacji</h4>
					<table id="infoTable" class="table table-condensed table-small break-word">
						<thead>
							<tr>
								<th width="8%">Kod</th>
								<th width="15%">Etykieta</th>
								<th width="16%">Opis</th>
								<th width="15%">Etykieta (en)</th>
								<th width="16%">Opis (en)</th>
								<th width="10%">Typ danych</th>
								<th width="18%">Domylna wartość</th>
								<th width="2%"></th>
							</tr>
						</thead>
						<tbody>
							<?php if ($this->appEditable instanceof ApplicationDataSets && $this->appEditable->getApplicationDataDefss()->count() > 0) : ?>
								<?php foreach ($this->appEditable->getApplicationDataDefss() as $def) : ?>
									<?php if ($def->getType() == 'info') : ?>
										<tr data-code="<?php echo $def->getCode(); ?>">
											<td><?php echo $def->getCode(); ?><input class="uniq-code data-code" type="hidden" value="<?php echo $def->getCode(); ?>" name="info[<?php echo $def->getCode(); ?>][code]"></td>
											<td><?php echo $def->getLabel(); ?><input class="data-label" type="hidden" value="<?php echo $def->getLabel(); ?>" name="info[<?php echo $def->getCode(); ?>][label]"></td>
											<td><?php echo $def->getDescription(); ?><input class="data-description" type="hidden" value="<?php echo $def->getDescription(); ?>" name="info[<?php echo $def->getCode(); ?>][desc]"></td>
											<td><?php echo $def->getLabelEn(); ?><input class="data-labelEn" type="hidden" value="<?php echo $def->getLabelEn(); ?>" name="info[<?php echo $def->getCode(); ?>][labelEn]"></td>
											<td><?php echo $def->getDescriptionEn(); ?><input class="data-descriptionEn" type="hidden" value="<?php echo $def->getDescriptionEn(); ?>" name="info[<?php echo $def->getCode(); ?>][descEn]"></td>
											<td><?php echo $def->getValueType(); ?><input class="data-type" type="hidden" value="<?php echo $def->getValueType(); ?>" name="info[<?php echo $def->getCode(); ?>][type]"></td>
											<td><?php echo $def->getDefaultValue(); ?><input class="data-default" type="hidden" value="<?php echo $def->getDefaultValue(); ?>" name="info[<?php echo $def->getCode(); ?>][default]"></td>
											<td class="actions">
												<i class="glyphicon glyphicon-pencil editInfo" title="edytuj"></i>
												<i class="glyphicon glyphicon-minus red removeInfo" title="usuń"></i>
											</td>
										</tr>
									<?php endif; ?>
								<?php endforeach; ?>
							<?php endif; ?>
						</tbody>
					</table>
					<button id="showAddInfoDialog" class="btn btn-default btn-sm" type="button"><i class="glyphicon glyphicon-plus"></i> Dodaj definicję informacji</button>
				</div>
				<h4>Linki</h4>
				<table id="linkTable" class="table table-condensed table-small break-word">
					<thead>
						<tr>
							<th width="8%">Kod</th>
							<th width="15%">Etykieta</th>
							<th width="21%">Opis</th>
							<th width="15%">Etykieta (en)</th>
							<th width="21%">Opis (en)</th>
							<th width="18%">Domylna wartość</th>
							<th width="2%"></th>
						</tr>
					</thead>
					<tbody>
						<?php if ($this->appEditable instanceof ApplicationDataSets && $this->appEditable->getApplicationDataDefss()->count() > 0) : ?>
							<?php foreach ($this->appEditable->getApplicationDataDefss() as $def) : ?>
								<?php if ($def->getType() == 'link') : ?>
									<tr data-code="<?php echo $def->getCode(); ?>">
										<td><?php echo $def->getCode(); ?><input class="uniq-code data-code" type="hidden" value="<?php echo $def->getCode(); ?>" name="link[<?php echo $def->getCode(); ?>][code]"></td>
										<td><?php echo $def->getLabel(); ?><input class="data-label" type="hidden" value="<?php echo $def->getLabel(); ?>" name="link[<?php echo $def->getCode(); ?>][label]"></td>
										<td><?php echo $def->getDescription(); ?><input class="data-description" type="hidden" value="<?php echo $def->getDescription(); ?>" name="link[<?php echo $def->getCode(); ?>][desc]"></td>
										<td><?php echo $def->getLabelEn(); ?><input class="data-labelEn" type="hidden" value="<?php echo $def->getLabelEn(); ?>" name="link[<?php echo $def->getCode(); ?>][labelEn]"></td>
										<td><?php echo $def->getDescriptionEn(); ?><input class="data-descriptionEn" type="hidden" value="<?php echo $def->getDescriptionEn(); ?>" name="link[<?php echo $def->getCode(); ?>][descEn]"></td>
										<td><?php echo $def->getDefaultValue(); ?><input class="data-default" type="hidden" value="<?php echo $def->getDefaultValue(); ?>" name="link[<?php echo $def->getCode(); ?>][default]"></td>
										<td class="actions">
											<i class="glyphicon glyphicon-pencil editLink" title="edytuj"></i>
											<i class="glyphicon glyphicon-minus red removeLink" title="usuń"></i>
										</td>
									</tr>
								<?php endif; ?>
							<?php endforeach; ?>
						<?php endif; ?>
					</tbody>
				</table>
				<button id="showAddLinkDialog" class="btn btn-default btn-sm" type="button"><i class="glyphicon glyphicon-plus"></i> Dodaj link</button>
		  </div>
		  <div class="panel-footer">
		  	<button id="registerSaveSubmit" class="btn btn-default btn-sm" type="submit" value="save"><i class="glyphicon glyphicon-floppy-disk"></i> Zapisz</button>
		  	<button id="toAcceptSubmit" class="btn btn-default btn-sm" type="submit" value="accept"><i class="glyphicon glyphicon-ok"></i> Zgłoś do akceptacji</button>
		  </div>
		</div>
	</form>
	<div id="addInfoModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="addInfoModalLabel" aria-hidden="true">
	  <div class="modal-dialog">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
	        <h4 class="modal-title" id="addInfoModalLabel">Dodaj definicję informacji</h4>
	      </div>
	      <form id="addInfoForm" class="form-horizontal" role="form">
	      	<div class="errorBox"></div>
	      	<div class="modal-body">
	        	<div class="form-group">
							<label for="inputInfoCode" class="col-xs-3 control-label">Kod</label>
							<div class="col-xs-9">
								<div class="input-group">
						      <input type="text" class="form-control required" id="inputInfoCode" name="code" placeholder="np. qwerty" maxlength="6">
						      <span class="input-group-addon">*</span>
					      </div>
					    </div>
						</div>
	        	<div class="form-group">
							<label for="inputInfoLabel" class="col-xs-3 control-label">Edykieta</label>
							<div class="col-xs-9">
								<div class="input-group">
						      <input type="text" class="form-control required" id="inputInfoLabel" name="label" placeholder="np. Liczba nieprzeczytanych wiadomoci">
						      <span class="input-group-addon">*</span>
						     </div>
					    </div>
						</div>
						<div class="form-group">
							<label for="inputInfoDesc" class="col-xs-3 control-label">Opis</label>
							<div class="col-xs-9">
					      <textarea class="form-control" id="inputInfoDesc" name="desc" placeholder="Opis w języku polskim"></textarea>
					    </div>
						</div>
						<div class="form-group">
							<label for="inputInfoEnLabel" class="col-xs-3 control-label">Edykieta (en)</label>
							<div class="col-xs-9">
								<div class="input-group">
						      <input type="text" class="form-control required" id="inputInfoEnLabel" name="labelEn" placeholder="np. Unread messages">
						      <span class="input-group-addon">*</span>
					      </div>
					    </div>
						</div>
						<div class="form-group">
							<label for="inputInfoDesc" class="col-xs-3 control-label">Opis (en)</label>
							<div class="col-xs-9">
					      <textarea class="form-control" id="inputInfoEnDesc" name="descEn" placeholder="Opis w języku angielskim"></textarea>
					    </div>
						</div>
						<div class="form-group">
							<label for="selectValueTypeLabel" class="col-xs-3 control-label">Typ danych</label>
							<div class="col-xs-9">
								<select id="selectValueTypeLabel" name="type">
									<option>string</option>
									<option>int</option>
									<option>bool</option>
								</select>
					    </div>
						</div>
						<div class="form-group">
							<label for="inputInfoDefault" class="col-xs-3 control-label">Domylna wartość</label>
							<div class="col-xs-9">
								<div class="input-group">
						      <input class="form-control required" id="inputInfoDefault" name="default" placeholder="np. 0" />
						      <span class="input-group-addon">*</span>
						    </div>
					    </div>
						</div>
						<div class="row">
							<div class="col-xs-9 col-xs-offset-3">* - pola wymagane</div>
						</div>
		      </div>
		      <div class="modal-footer">
		        <button type="button" class="btn btn-primary" data-dismiss="modal">Zamknij</button>
		        <button id="addInfoForm-add" type="submit" class="btn btn-default">Dodaj</button>
		      </div>
		    </form>
		  </div>
	  </div>
	</div>
	<div id="addLinkModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="addInfoModalLabel" aria-hidden="true">
	  <div class="modal-dialog">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
	        <h4 class="modal-title" id="addInfoModalLabel">Dodaj link</h4>
	      </div>
	      <form id="addLinkForm" class="form-horizontal" role="form">
	      	<div class="errorBox"></div>
	      	<div class="modal-body">
	        	<div class="form-group">
							<label for="inputLinkCode" class="col-xs-3 control-label">Kod</label>
							<div class="col-xs-9">
								<div class="input-group">
						      <input type="text" class="form-control required" id="inputLinkCode" name="code" placeholder="np. qwerty" maxlength="6">
						      <span class="input-group-addon">*</span>
						     </div>
					    </div>
						</div>
	        	<div class="form-group">
							<label for="inputLinkLabel" class="col-xs-3 control-label">Edykieta</label>
							<div class="col-xs-9">
								<div class="input-group">
						      <input type="text" class="form-control required" id="inputLinkLabel" name="label" placeholder="np. Przejdź do strony vw-group">
						      <span class="input-group-addon">*</span>
						     </div>
					    </div>
						</div>
						<div class="form-group">
							<label for="inputLinkDesc" class="col-xs-3 control-label">Opis</label>
							<div class="col-xs-9">
					      <textarea class="form-control" id="inputLinkDesc" name="desc" placeholder="Opis w języku polskim"></textarea>
					    </div>
						</div>
						<div class="form-group">
							<label for="inputLinkEnLabel" class="col-xs-3 control-label">Edykieta (en)</label>
							<div class="col-xs-9">
								<div class="input-group">
						      <input type="text" class="form-control required" id="inputLinkEnLabel" name="labelEn" placeholder="np. vw-group home page">
						      <span class="input-group-addon">*</span>
						     </div>
					    </div>
						</div>
						<div class="form-group">
							<label for="inputLinkDesc" class="col-xs-3 control-label">Opis (en)</label>
							<div class="col-xs-9">
					      <textarea class="form-control" id="inputLinkEnDesc" name="descEn" placeholder="Opis w języku angielskim"></textarea>
					    </div>
						</div>
						<div class="form-group">
							<label for="inputLinkDefault" class="col-xs-3 control-label">Domyślny url</label>
							<div class="col-xs-9">
								<div class="input-group">
					      	<input class="form-control required" id="inputLinkDefault" name="default" placeholder="np. http://www.vw-group.pl/" />
					      	<span class="input-group-addon">*</span>
						     </div>
					    </div>
						</div>
						<div class="row">
							<div class="col-xs-9 col-xs-offset-3">* - pola wymagane</div>
						</div>
		      </div>
		      <div class="modal-footer">
		        <button type="button" class="btn btn-primary" data-dismiss="modal">Zamknij</button>
		        <button id="addLinkForm-add" type="submit" class="btn btn-default">Dodaj</button>
		      </div>
		    </form>
		  </div>
	  </div>
	</div>
<?php endif; ?>